﻿using CleanArchitecture.Infrastructure.Entities.Business;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace CleanArchitecture.Infrastructure.DataMapping.Business
{
    /// <summary>
    /// Represents a picture mapping configuration
    /// </summary>
    public partial class FileUploadMap : NowaEntityTypeConfiguration<FileUpload>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<FileUpload> builder)
        {
            builder.ToTable("bus_fileupload");
            builder.HasKey(file => file.Id);

            builder.Property(file => file.MimeType).HasMaxLength(40).IsRequired();
            builder.Property(file => file.SeoFilename).HasMaxLength(300);
            builder.Property(file => file.Category).HasMaxLength(50);
            builder.Property(file => file.AltAttribute).HasMaxLength(500);
            builder.Property(file => file.TitleAttribute).HasMaxLength(500);
            builder.Property(file => file.VirtualPath).HasMaxLength(1000);
            builder.Property(file => file.LinkUrl).HasMaxLength(300);
            //builder.HasOne(file => file.FileBinary)
            //    .WithOne()
            //    .HasForeignKey<FileBinary>(fileBinary => fileBinary.FKFileUploadId)
            //    .OnDelete(DeleteBehavior.NoAction);
            base.Configure(builder);
        }

        #endregion
    }
}
